package com.ddone.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author ddone
 * @date 2024/3/25-12:48
 */

@SpringBootConfiguration
public class DataSourceAutoConfiguration {

    @Autowired
    private DatasourceConfigProp datasourceConfigProp;

    @Bean()
    public DataSource dataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(datasourceConfigProp.getDriverClassName());
        dataSource.setUrl(datasourceConfigProp.getUrl());
        dataSource.setUsername(datasourceConfigProp.getUsername());
        dataSource.setPassword(datasourceConfigProp.getPassword());
        return dataSource;
    }


}
